package com.lwt.common;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

public class AnnoUtils<T> {

    public static <T extends Annotation> T getAnno(ProceedingJoinPoint joinPoint, Class<T> clazz) {
        //获取注解的方法
        Method method = getMethod(joinPoint);
        return method.getAnnotation(clazz);
    }

    public static Parameter[] getParam(ProceedingJoinPoint joinPoint) {
        Method method = getMethod(joinPoint);
        return method.getParameters();
    }

    public static Method getMethod(ProceedingJoinPoint joinPoint) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        return signature.getMethod();
    }


}
